#ifndef MEMBERACCOUNT_CPP
#define MEMBERACCOUNT_CPP

#include "MemberAccount.h"
#include "DB.h"

MemberAccount::MemberAccount(){
    
	vector<string> rGF, rRF; 
		this->reviewGrantedFor = rGF;
		this->reviewRequestedFor = rRF;		
    this->memberID = "";
    this->memberName = "";
    this->memberPassword = "";
    this->rewardsPoints = 0;
		this->type = "";
}

MemberAccount::MemberAccount(string ID, string Name, string pwd, int rwdPoints)
{
	vector<string> rGF, rRF; 
    this->memberID = ID;
    this->memberName = Name;
    this->memberPassword = pwd;
		this->reviewGrantedFor = rGF;
		this->reviewRequestedFor = rRF;		
    this->rewardsPoints = rwdPoints;
		this->type = "";		
}

MemberAccount::MemberAccount(void* a) 
{
    this->memberID = (*(static_cast<MemberAccount*>(a))).memberID; ;
    this->memberName = (*(static_cast<MemberAccount*>(a))).memberName;
    this->memberPassword = (*(static_cast<MemberAccount*>(a))).memberPassword;
    this->reviewGrantedFor = (*(static_cast<MemberAccount*>(a))).reviewGrantedFor;
    this->reviewRequestedFor = (*(static_cast<MemberAccount*>(a))).reviewRequestedFor;		
    this->rewardsPoints = (*(static_cast<MemberAccount*>(a))).rewardsPoints;
    this->authenticate = (*(static_cast<MemberAccount*>(a))).authenticate;
    this->type = (*(static_cast<MemberAccount*>(a))).type;
}


MemberAccount::~MemberAccount(){
    
}

string MemberAccount::getMemberID()
{
    return this->memberID;
}

string MemberAccount::getMemberName()
{
    return this->memberName;
}

string MemberAccount::getMemberPassword()
{
    return this->memberPassword;
}

int MemberAccount::getRewardPoints()
{
    return this->rewardsPoints;
}

bool MemberAccount::getAuthenticate()
{
    return this->authenticate;
}

string MemberAccount::getType()
{
    return this->type;
}

vector<string> MemberAccount::getReviewGrantedFor()
{
    return this->reviewGrantedFor;
}

vector<string> MemberAccount::getReviewRequestedFor()
{
	return this->reviewRequestedFor;
}

void MemberAccount::setMemberID(string ID)
{
    this->memberID = ID;
}

void MemberAccount::setMemberName(string name)
{
    this->memberName = name;
}

void MemberAccount::setMemberPassword(string pwd)
{
    this->memberPassword = pwd;
}

void MemberAccount::setRewardPoints(int rwdPts)
{
    this->rewardsPoints = rwdPts;
}

void MemberAccount::setAuthenticate(bool aut)
{
    this->authenticate = aut;
}

void MemberAccount::setType(string str)
{
    this->type = str;
}

void MemberAccount::setReviewGrantedFor(vector<string> vec)
{
	this->reviewGrantedFor = vec;
}

void MemberAccount::setReviewRequestedFor(vector<string> vec)
{
	this->reviewRequestedFor = vec;
}

void MemberAccount::viewHotelReview()
{
	vector<HotelReview> vec;
	dbHotelReview('s', vec);
    
    cout << "All Hotel Reviews " << endl ;
    drawLine('=', 105);
    
    cout << setw(3) << "No"
         << setw(11) << "Review ID"
         << setw(11) << "Hotel ID"
         << setw(11) << "Member ID"
         << setw(10) << "Location"
         << setw(20) << "Value For Money"
         << setw(10) << "Comfort"
         << setw(10) << "Service"
         << endl;
    
    cout << setw(46) << "Rating"
         << setw(20) << "Rating"
         << setw(10) << "Rating"
         << setw(10) << "Rating"
         << endl;
    
    drawLine('-', 105);
		
		drawLine('-',15);
		for(int i = 0 ; i < vec.size(); i++)
		{
		cout << setw(3)  << i+1
				 << setw(11) << vec[i].getReviewId()
				 << setw(11) << vec[i].getHotelId()
				 << setw(11) << vec[i].getCustomerId()
				 << setw(10) << vec[i].getLocationRating()
				 << setw(20) << vec[i].getValueForMoneyRating()
				 << setw(10) << vec[i].getComfortRating()
				 << setw(10) << vec[i].getServiceRating()
				 << endl;

		cout << endl << "Average Rating : " << vec[i].getAverageRating() << endl;        
		cout << "Comments       : " << vec[i].getComments() << endl;
		drawLine('-',15);
		}
    
    if(vec.empty())
    {
        cout << "There are no review!" << endl;
    }
    
    drawLine('=',50);        
}

void MemberAccount::searchHotel()
{
	  vector<HotelItem> hotelItemVec;
    dbHotelItem('s', hotelItemVec);
    
    bool continueOption = true;
    string userKeyStr;
    char* userKey = new char;
    userKey[0] = ' ';

    while(userKey[0] != 'g')
    {
        cout << "Choose From The Categories below: " << endl;
        cout << "a)One Star" << endl;
        cout << "b)Two Star" << endl;
        cout << "c)Three Star" << endl;
        cout << "d)Four Star" << endl;
        cout << "e)Five Star" << endl;
        cout << "f)All Hotels" << endl;
        cout << "g)Back to Menu" << endl;
        
        cout << endl << "Your Option : " ;
        getline(cin, userKeyStr);
        strcpy(userKey,userKeyStr.c_str());
        
        if(userKeyStr.length() > 1)
            cout << "Error: Detected a Sentence. Retry!" << endl << endl;
        else if((userKey[0] = tolower(userKey[0])) && (!(userKey[0] >= 'a' && userKey[0] <= 'g')))
        {
            cout << "Error : Invalid Option!. Retry!" << endl << endl;
        }
        else
        {
            continueOption = false;
            vector<HotelItem>::iterator p = hotelItemVec.begin();
            
            if(userKey[0] != 'g')
            {
                cout << endl << "Hotel Details " << endl ;
                drawLine('=', 105);
 
                cout << setw(3)  << "No"
                     << setw(10)  << "Hotel ID"
                     << setw(25) << "Hotel Name"
                     << setw(35) << "Address"
                     << setw(15) << "District"   
                     << setw(15) << "Country"
                     << endl;
    
                drawLine('-', 105);
            }
            
            int count = 0;
            float overallAvg;
            
            switch(userKey[0])
            {
                case 'a' :
                            cout << "One Star Hotels"<< endl;
                            drawLine('-',15);
                            
                            while(p != hotelItemVec.end())
                            {
                                if(p->getCategory() == "One Star")
                                {
                                    cout << setw(3)  << ++count
                                         << setw(10)  << p->getHotelID()
                                         << setw(25) << p->getName()
                                         << setw(35) << p->getAddress()
                                         << setw(15) << p->getDistrict()
                                         << setw(15) << p->getCountry()
                                         << endl;
                                    
                                    dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                    cout << "   Review Overall Rating : " << overallAvg << endl;
                                    drawLine('-',15);
                                }                       
                                ++p;
                            }      
                    break;
                    
                case 'b' : 
                            cout << "Two Star Hotels"<< endl;
                            drawLine('-',15);
                            
                            while(p != hotelItemVec.end())
                            {
                                if(p->getCategory() == "Two Star")
                                {
                                    cout << setw(3)  << ++count
                                         << setw(10)  << p->getHotelID()
                                         << setw(25) << p->getName()
                                         << setw(35) << p->getAddress()
                                         << setw(15) << p->getDistrict()
                                         << setw(15) << p->getCountry()
                                         << endl;
                                    
                                    dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                    cout << "  Review Overall Rating : " << overallAvg << endl;
                                    drawLine('-',15);
                                }                       
                                ++p;
                            }       
                    break;
                    
                case 'c' : 
                            cout << "Three Star Hotels"<< endl;
                            drawLine('-',15);
                            
                            while(p != hotelItemVec.end())
                            {
                                if(p->getCategory() == "Three Star")
                                {
                                    cout << setw(3)  << ++count
                                         << setw(10) << p->getHotelID()
                                         << setw(25) << p->getName()
                                         << setw(35) << p->getAddress()
                                         << setw(15) << p->getDistrict()
                                         << setw(15) << p->getCountry()
                                         << endl;
                                    
                                    dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                    cout << "  Review Overall Rating : " << overallAvg << endl;
                                    drawLine('-',15);
                                }                       
                                ++p;
                            }    
                    break;
                    
                case 'd' : 
                            cout << "Four Star Hotels"<< endl;
                            drawLine('-',15);
                            
                            while(p != hotelItemVec.end())
                            {
                                if(p->getCategory() == "Four Star")
                                {
                                   cout << setw(3)  << ++count
                                         << setw(10) << p->getHotelID()
                                         << setw(25) << p->getName()
                                         << setw(35) << p->getAddress()
                                         << setw(15) << p->getDistrict()
                                         << setw(15) << p->getCountry()
                                         << endl;
                                   
                                   dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                   
                                   cout << "  Review Overall Rating : " << overallAvg << endl;
                                   drawLine('-',15);
                                }                       
                                ++p;
                            }    
                    break;
                    
                case 'e' : 
                            cout << "Five Star Hotels"<< endl;
                            drawLine('-',15);
                            
                            while(p != hotelItemVec.end())
                            {
                                if(p->getCategory() == "Five Star")
                                {
                                    cout << setw(3)  << ++count
                                         << setw(10) << p->getHotelID()
                                         << setw(25) << p->getName()
                                         << setw(35) << p->getAddress()
                                         << setw(15) << p->getDistrict()
                                         << setw(15) << p->getCountry()
                                         << endl;
                                    
                                    dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                    cout << "  Review Overall Rating : " << overallAvg << endl;
                                    drawLine('-',15);
                                }                       
                                ++p;
                            }    
                    break;
                    
                case 'f' : 
                            for(int i = 0 ; i < 5; i++)
                            {
                                p = hotelItemVec.begin();
                                count = 0;
                                
                                if(i == 0)
                                {
                                    cout << "One Star Hotels"<< endl;
                                    drawLine('-',15);
                                    
                                    while(p != hotelItemVec.end())
                                    {
                                        if(p->getCategory() == "One Star")
                                        {
                                            cout << setw(3)  << ++count
                                                 << setw(10) << p->getHotelID()
                                                 << setw(25) << p->getName()
                                                 << setw(35) << p->getAddress()
                                                 << setw(15) << p->getDistrict()
                                                 << setw(15) << p->getCountry()
                                                 << endl;
                                            
                                            dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                            cout << "  Review Overall Rating : " << overallAvg << endl;
                                            drawLine('-',15);
                                        }
                                        
                                        ++p;
                                    }  
                                }
                                else if(i == 1)
                                {
                                    cout << endl << "Two Star Hotels"<< endl;
                                    drawLine('-',15);
                                    
                                    while(p != hotelItemVec.end())
                                    {
                                        if(p->getCategory() == "Two Star")
                                        {
                                            cout << setw(3)  << ++count
                                                 << setw(10) << p->getHotelID()
                                                 << setw(25) << p->getName()
                                                 << setw(35) << p->getAddress()
                                                 << setw(15) << p->getDistrict()
                                                 << setw(15) << p->getCountry()
                                                 << endl;
                                            
                                            dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                            cout << "  Review Overall Rating : " << overallAvg << endl;
                                            drawLine('-',15);
                                        }
                                        
                                        ++p;
                                    }
                                }
                                else if(i == 2)
                                {
                                    cout << endl << "Three Star Hotels"<< endl;
                                    drawLine('-',15);
                                    
                                    while(p != hotelItemVec.end())
                                    {
                                        if(p->getCategory() == "Three Star")
                                        {
                                            cout << setw(3)  << ++count
                                                 << setw(10) << p->getHotelID()
                                                 << setw(25) << p->getName()
                                                 << setw(35) << p->getAddress()
                                                 << setw(15) << p->getDistrict()
                                                 << setw(15) << p->getCountry()
                                                 << endl;
                                            
                                            dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                            cout << "  Review Overall Rating : " << overallAvg << endl;
                                            drawLine('-',15);
                                        }
                                        
                                        ++p;
                                    }
                                }
                                else if(i == 3)
                                {
                                    cout << endl << "Four Star Hotels"<< endl;
                                    drawLine('-',15);
                                    
                                    while(p != hotelItemVec.end())
                                    {
                                        if(p->getCategory() == "Four Star")
                                        {
                                            cout << setw(3)  << ++count
                                                 << setw(10) << p->getHotelID()
                                                 << setw(25) << p->getName()
                                                 << setw(35) << p->getAddress()
                                                 << setw(15) << p->getDistrict()
                                                 << setw(15) << p->getCountry()
                                                 << endl;
                                            
                                            dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                            cout << "  Review Overall Rating : " << overallAvg << endl;
                                            drawLine('-',15);
                                        }
                                        
                                        ++p;
                                    }
                                }
                                else if(i == 4)
                                {
                                    cout << endl << "Five Star Hotels"<< endl;
                                    drawLine('-',15);
                                    
                                    while(p != hotelItemVec.end())
                                    {
                                        if(p->getCategory() == "Five Star")
                                        {
                                            cout << setw(3)  << ++count
                                                 << setw(10) << p->getHotelID()
                                                 << setw(25) << p->getName()
                                                 << setw(35) << p->getAddress()
                                                 << setw(15) << p->getDistrict()
                                                 << setw(15) << p->getCountry()
                                                 << endl;
                                            
                                            dbGetAvgHotelRating(p->getHotelID(),overallAvg);
                                    
                                            cout << "  Review Overall Rating : " << overallAvg << endl;
                                            drawLine('-',15);
                                        }
                                        
                                        ++p;
                                    }
                                }
                            }  
                    break;
                    
                case 'g' : cout << endl << "Exiting Search Hotel ... " << endl;
                    break;
            }
            
            drawLine('=', 105);
            cout << endl;
        }

    }
}

void MemberAccount::createHotelReview()
{   
    vector<HotelReview> hotelRevVec;
		vector<HotelReview> hotelRevToInsVec;
		dbHotelReview('s', hotelRevVec);
    
    string temp,tempReviewID,tempHotelId,tempCusId,tempComments;
    int tempLocRat, tempValforMonRat, tempComfotRat, tempSerRat;
    float tempAvgRat;
    string delimiter = "|";
    size_t pos = 0;
    
    vector<HotelReview>::iterator p = hotelRevVec.begin();
    p = p + (hotelRevVec.size()-1);
    
    string lastReviewId = p->getReviewId();
    string nextReviewId;

    if(hotelRevVec.size() == 0)
    {
        nextReviewId = "HR00001"; 
    }
    else
    {
        lastReviewId = lastReviewId.substr(2,5);
        
        int lasId = atoi(lastReviewId.c_str());
        lasId++;
        
        char ch_num[4];
        nextReviewId = "HR";
        
        if(lasId < 10)
            nextReviewId += "0000";
        else if(lasId < 100)
            nextReviewId += "000";
        else if(lasId < 1000)
            nextReviewId += "00";
        else if(lasId < 10000)
            nextReviewId += "0";
            
        stringstream ss;
        ss << lasId;
        
        nextReviewId += ss.str();       
    }

    cout << "Create a New Hotel Review" << endl;
    drawLine('-',50); 
    cout << "Customer Id : " << getMemberID() << endl;
    cout << "Review Id   : " << nextReviewId << endl;
    
    drawLine('-',10);
    cout << "Hotel Id    : ";
    bool correctHotelId = false;
    bool granted = false;
    bool quit = false;
    
    vector<HotelItem> hotelItemVec;
    dbHotelItem('s', hotelItemVec);
		
    while(!correctHotelId && !quit)
    {
        getline(cin,tempHotelId);
        
        correctHotelId = HotelItem::validHotelId(hotelItemVec,tempHotelId);
        
        vector<string>::iterator p = reviewGrantedFor.begin();
        
        while(p != reviewGrantedFor.end() && !granted)
        {
            if((*p) == tempHotelId)
                granted = true;
            
            ++p;
        }
        
        if(!correctHotelId && tempHotelId != "q")
            cout << "Error: Invalid Hotel Id! Re-Enter Hotel Id  : ";
        else if (!granted && tempHotelId != "q")
        {
            cout << "Error: Review for Hotel '" << tempHotelId << "' is not Granted! Re-Enter Hotel Id ('q' to quit) : ";
            correctHotelId = false;
        }
        else if (tempHotelId == "q")
            quit = true;
    }
    
    if(!quit)
    {
        cout << "Location Rating        (Any Number from 1 to 5) : ";
        tempLocRat = validRating();

        cout << "Value For Money Rating (Any Number from 1 to 5) : ";
        tempValforMonRat = validRating();
    
        cout << "Comfort Rating         (Any Number from 1 to 5) : ";
        tempComfotRat = validRating();
    
        cout << "Service Rating         (Any Number from 1 to 5) : ";
        tempSerRat = validRating();
    
        tempAvgRat = ((float)(tempLocRat + tempValforMonRat + tempSerRat + tempComfotRat)) / 4;
   
        cout << "Average Rating : " << tempAvgRat << endl;
    
        cout << "Enter Your Comments (Less than 1000 words)      : " ;
    
        bool within1000 = false;
    
        while(!within1000)
        {
            getline(cin,tempComments);
            int words = 0;
        
            for(int i=0;tempComments[i]!='\0';i++)
            {
		if (tempComments[i]==' ')
			words++; 		
            }
        
            if(words > 1000)
            {
                cout << "Comment exceeds 1000 words. Please Re-enter Comment (less than 1000 words) :";
            }
            else
                within1000  = true;
        }
    
        HotelReview tempHotelRev(nextReviewId,tempHotelId,getMemberID(),
                                    tempLocRat,tempValforMonRat,tempComfotRat,
                                        tempSerRat,tempAvgRat,tempComments);
    
        hotelRevToInsVec.push_back(tempHotelRev);
    
        dbHotelReview('i', hotelRevToInsVec);
        cout << endl << "New Hotel Review added Successfully" << endl << endl;
    }
    else
        cout << endl << "Exiting Creation of Hotel Review ..." << endl << endl;
}

void MemberAccount::viewHotelItem(string viewType) // ViewType: NULL = All
                                                   //           Others = specific display (Eg.HI00001)
{
	vector<HotelItem> hotelItemVec;
	dbHotelItem('s', hotelItemVec);
    
	   if(viewType == "NULL")
    {    
        cout << "List Of Hotel & Its Information" << endl;
        drawLine('=',110);
        
        cout << setw(3)  << "No"
             << setw(10) << "Hotel ID"
             << setw(25) << "Hotel Name"
             << setw(35) << "Address"
             << setw(15) << "District"   
             << setw(15) << "Country"
             << setw(15) << "Category"
             << endl;
    
        drawLine('-',110);
        
				for(int i = 1; i <= hotelItemVec.size(); i++)
				{
            cout << setw(3)  << ++i
                 << setw(8) << hotelItemVec[i].getHotelID()
                 << setw(25) << hotelItemVec[i].getName()
                 << setw(25) << hotelItemVec[i].getAddress()
                 << setw(15) << hotelItemVec[i].getDistrict()
                 << setw(15) << hotelItemVec[i].getDistrict()
                 << setw(15) << hotelItemVec[i].getCategory()
                 << endl;
        }
    
        drawLine('=',110);
    }
    else
    {
			 	for(int i = 0; i < hotelItemVec.size(); i++)
				{            
					if(viewType == hotelItemVec[i].getHotelID())
          {
            cout << setw(10) << hotelItemVec[i].getHotelID()
                 << setw(25) << hotelItemVec[i].getName()
                 << setw(25) << hotelItemVec[i].getAddress()
                 << setw(15) << hotelItemVec[i].getDistrict()
                 << setw(15) << hotelItemVec[i].getDistrict()
                 << setw(15) << hotelItemVec[i].getCategory()
                 << endl;
					}
				}
    }
}

void MemberAccount::requestReviewPermission()
{    
    vector<HotelItem> allHotelId;
		dbHotelItem('s', allHotelId);
    
    string hotelId;
    bool correctRequest = false;
    
    cout << "Request Review" << endl;
    drawLine('-', 14);
    cout << "Member Id: " << getMemberID() << endl;
    
    while(!correctRequest)
    {
        cout << "Hotel Id (eg. HI00001. 'q' to Quit) : ";
        getline(cin,hotelId);
        
        string test;
        bool notAlpha = true;
        
        if((isalpha(hotelId[0])))
        {
            test = toupper(hotelId[0]);
            
            if(test != "Q")
            {
                hotelId[0] = toupper(hotelId[0]);
                
                if((isalpha(hotelId[1])))
                {
                    hotelId[1] = toupper(hotelId[1]);
                    notAlpha = false;
                }
            }
        }
                
        if(test == "Q" && hotelId.length() == 1)
        {
            correctRequest = true;
            cout << endl << "Returning back to Prev Menu ...." << endl << endl;
        }
        else if (notAlpha || (!(hotelId[0] == 'H' && hotelId[1] == 'I')))
        {
            cout << endl << "Error: Invalid Hotel Id Initials! Start with HI! Re-Enter ";
        }
        else
        {        
            vector<HotelItem>::iterator p = allHotelId.begin();
        
            while(p != allHotelId.end() && !correctRequest)
            {
                if(p->getHotelID() == hotelId)
                    correctRequest = true;
                ++p;
            }
        
            bool unique = true;
        
            if(correctRequest)
            {
                vector<string>::iterator q = reviewRequestedFor.begin();
        
                while(q != reviewRequestedFor.end() && unique)
                {
                    if((*q) == hotelId)
                        unique = false;
            
                    ++q;
                }
            }
            
            bool havePer = false;
            
            if(!havePer)
            {
                vector<string>::iterator q = reviewGrantedFor.begin();
                
                while(q != reviewGrantedFor.end() && !havePer)
                {
                    if((*q) == hotelId)
                        havePer = true;
            
                    ++q;
                }
            }
        
            if(correctRequest && unique && !havePer)
            {            
                reviewRequestedFor.push_back(hotelId);
                cout << endl << "Request is made Successfully!" << endl << endl;
            }
            else if(!correctRequest)
            {
                cout << "Error: Invalid Hotel Id! Re-enter ";
            }
            else if(!unique)
            {
                correctRequest = false;
                cout << "Error: Request Already Made! Re-enter ";
            }
            else if (havePer)
            {
                correctRequest = false;
                cout << "Error: Permission for this hotel is already GIVEN! Re-enter ";
            }
        }   
    }
		//vector<string> tmp = getReviewRequestedFor();
		//cout << vecStrToStr(tmp) << endl;
		vector<MemberAccount*> maToUpd;
		maToUpd.push_back(this);
		dbMemberAccount('u', maToUpd);
}

void MemberAccount::viewPermitedHotel()
{
    if(reviewGrantedFor.size() == 0)
    {
        cout << "You are not permitted to write review on ANY Hotels!! If "
             << "you want to write a review, Put up a request to write review "
             << "on the hotel of your choice below." << endl << endl;
        
        bool validChar = false;
        string ch = " ";
        

        
        while(!validChar)
        {
            cout << "Would You like to put up a request? (y/n): ";
            cin >> ch;        
						cin.clear();
						cin.ignore(100,'\n');
            cout << endl;
            
            if(ch.length() > 1)
                cout << "Error: Detected a Sentence! Re-Enter Option! ";
            else
            {
                ch = tolower(ch[0]);
                
                if(ch[0] == 'n' || ch[0] == 'y')
                {
                    validChar = true;
                    
                    if(ch[0] == 'y')
                    {
                        requestReviewPermission();
                    }
                    else if(ch[0] == 'n')
                    {
                        cout << endl << "Returning to previous menu..." << endl << endl;
                    }
                }
                else
                {
                    cout << "Error: Invalid Option! Re-enter Option! ";
                }
            }
        }
    }
    else
    {
        vector<string>::iterator p = reviewGrantedFor.begin();
    
        cout << "Hotels Permitted to create reviews on" << endl;
        drawLine('=', 38);
    
        cout << setw(3)  << "No"
             << setw(10) << "Hotel ID"
             << setw(25) << "Hotel Name"
             << setw(35) << "Address"
             << setw(15) << "District"   
             << setw(15) << "Country"
             << endl;
    
            drawLine('-', 105);
            
            int count = 0;
    
            while(p != reviewGrantedFor.end())
            {
                cout << setw(3) << ++count;
                viewHotelItem(*p);
                ++p;
            }
    
            drawLine('=', 105);
            cout << endl;
    }
}

bool MemberAccount::operator==(MemberAccount& bMember){
    
    MemberAccount aMember=*this;
    
    if(aMember.getMemberID() == bMember.getMemberID()){
        if(aMember.getMemberName() == bMember.getMemberName()){
            if(aMember.getMemberPassword() == bMember.getMemberPassword()){
                if(aMember.getRewardPoints() == bMember.getRewardPoints()){
                    return true;
                }
            }
        }
    }
        return false;
    
}

istream& operator>>(istream& in, MemberAccount& anAccount){
    
    string temp;
    
    cout<<"Please Enter Userid:";
    getline(cin, temp);
    anAccount.setMemberID(temp);
    
    cout<<"Please Enter Password:";
    getline(cin, temp);
    anAccount.setMemberPassword(temp);
    
    
    return in;
}

ostream& operator<<(ostream& out, MemberAccount& rAccount){
    
    out<<rAccount.getRewardPoints()<<endl;
    return out;
}

void MemberAccount::operator =(const MemberAccount& M)
{
    this->memberID = M.memberID;
    this->memberName = M.memberName;
    this->memberPassword = M.memberPassword;
    this->reviewGrantedFor = M.reviewGrantedFor;
    this->reviewRequestedFor = M.reviewRequestedFor;		
    this->rewardsPoints = M.rewardsPoints;
    this->type = M.type;
    this->authenticate = M.authenticate;
}

#endif